package com.zjitc.controller;

import com.zjitc.pojo.Product;
import com.zjitc.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;

/**
 * Create By IntelliJ IDEA
 *
 * @author:
 * @create-Time: 2017/11/11  16:33
 */
@Controller
public class Indexcontroller {

    @Autowired
    private ProductService service;

    @RequestMapping("/index")
    public ModelAndView index(){
        List<Product> hots = service.findHots();
        List<Product> news = service.findNews();
        ModelAndView mv = new ModelAndView();
        mv.addObject("hots",hots);
        mv.addObject("news",news);
        mv.setViewName("index");
        return mv;
    }


    @RequestMapping("/gotoaddress")
    public ModelAndView gotoaddress(String  address){
      ModelAndView modelAndView = new ModelAndView();
      modelAndView.setViewName(address);
      return modelAndView;
    }
}
